// ============================== 导入依赖 ============================== //

// ============================== 导出计算属性 ============================== //

export default {
  /**
   * 自定义计算属性 (可覆盖)
   */
  GETTER: ({ DICT: { STATUS }, MAP: { COUNT }, one }, getters) => {
    const transStatus = ([id, name, code, color]) => [id, name, COUNT[code] || 0, color]
    const checkService = (dict) => dict[3] === one.manufacturerId && dict[4] === one.deviceTypeId

    return {
      STATUS: STATUS.map(transStatus), // 带统计数量的状态字典

      hasIP: ['1', '2', '3', '4'].includes(one.deviceCategoryId), // 是否包含 IP 等信息

      filterService: getters['service/selectDict'].filter(checkService), // 过滤的服务字典

      aiPoint: getters['point/selectDict'].filter((dict) => dict[2] === 0), // AI 模拟输入点位
      aoPoint: getters['point/selectDict'].filter((dict) => dict[2] === 1), // AO 模拟输出点位
      diPoint: getters['point/selectDict'].filter((dict) => dict[2] === 3), // DI 数字输入点位
      doPoint: getters['point/selectDict'].filter((dict) => dict[2] === 4), // DO 数字输出点位
    }
  },
}
